package com.fuzhixuan.cloud.entities;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonResult<T> {
    private Integer code;
    private String msg;
    private T data;

    public CommonResult(Integer code) {
        this(code, "", null);
    }

    public CommonResult(Integer code, String msg) {
        this(code, msg, null);
    }

    public static CommonResult ok(Integer successCode) {
        return new CommonResult(successCode);
    }

    public static CommonResult fail(Integer failureCode, String msg) {
        return new CommonResult(failureCode, msg);
    }

    public static CommonResult ok(Integer successCode, Object result) {
        return new CommonResult(successCode, "数据执行成功", result);
    }
}
